<script setup>
import { useRouter } from 'vue-router'
import {
  Menu as IconMenu,
  Document,
  User,
  Edit,
  Collection,
  Reading,
  Briefcase,
  Search,
  ChatLineRound,
  Notebook,
  Position
} from '@element-plus/icons-vue'

const router = useRouter()

const navigate = (path) => {
  router.push(path)
}

const cards = [
  {
    title: '登录',
    desc: '已有账号快速登录',
    path: '/login',
    icon: User,
    color: 'purple',
    bgColor: 'linear-gradient(135deg, #5f27cd, #8c7ae6)'
  },
  {
    title: '注册',
    desc: '新用户注册账号',
    path: '/register',
    icon: Edit,
    color: 'blue',
    bgColor: 'linear-gradient(135deg, #0984e3, #74b9ff)'
  },
  {
    title: '论坛交流',
    desc: '求职招聘交流区',
    path: '/meet',
    icon: ChatLineRound,
    color: 'green',
    bgColor: 'linear-gradient(135deg, #006266, #00b894)'
  },
  {
    title: '求职指南',
    desc: '求职技巧与资料',
    path: '/resources',
    icon: Notebook,
    color: 'orange',
    bgColor: 'linear-gradient(135deg, #e67e22, #f39c12)'
  },
  {
    title: '发布求职',
    desc: '发布求职需求',
    path: '/seek',
    icon: Search,
    color: 'cyan',
    bgColor: 'linear-gradient(135deg, #2ecc71, #27ae60)'
  },
  {
    title: '发布招聘',
    desc: '发布招聘职位',
    path: '/recruit',
    icon: Briefcase,
    color: 'red',
    bgColor: 'linear-gradient(135deg, #b71540, #e17055)'
  },
  {
    title: '职位浏览',
    desc: '查看所有招聘职位',
    path: '/dashboard',
    icon: Position,
    color: 'indigo',
    bgColor: 'linear-gradient(135deg, #e84393, #fd79a8)'
  },
  {
    title: '人才库',
    desc: '浏览求职者信息',
    path: '/jobs',
    icon: Collection,
    color: 'teal',
    bgColor: 'linear-gradient(135deg, #1e3799, #4a69bd)'
  }
]
</script>

<template>
  <div class="common-layout">
    <el-container class="layout-container">
      <!-- 侧边导航栏 -->
      <el-aside width="220px" class="aside">
        <div class="aside-content">
          <div class="logo-area">
            <h2>Win-Win Platform</h2>

          </div>
          <el-menu
            active-text-color="#ffd04b"
            background-color="#2c3e50"
            text-color="#ecf0f1"
            class="menu"
            :default-active="$route.path"
            router
          >
            <el-menu-item index="/dashboard" @click="navigate('/dashboard')">
              <el-icon><Position /></el-icon>
              <span>职位浏览</span>
            </el-menu-item>
            <el-menu-item index="/jobs" @click="navigate('/jobs')">
              <el-icon><User /></el-icon>
              <span>人才浏览</span>
            </el-menu-item>
          </el-menu>
        </div>
      </el-aside>

      <!-- 主内容区 -->
      <el-container>
        <el-header class="header">
          <div class="header-content">
            <h1>欢迎进入！</h1>
            <p class="subtitle">连接优秀人才与企业，创造双赢机会</p>
          </div>
        </el-header>

        <el-main class="main">
          <router-view />

          <div class="card-container">
            <h3 class="section-title">快速入口</h3>
            <el-row :gutter="20">
              <el-col
                :span="6"
                v-for="(item, index) in cards"
                :key="index"
                @click="navigate(item.path)"
              >
                <div
                  class="grid-content"
                  :style="{ background: item.bgColor }"
                >
                  <div class="card-content">
                    <el-icon size="32px" class="icon">
                      <component :is="item.icon" />
                    </el-icon>
                    <h3>{{ item.title }}</h3>
                    <p>{{ item.desc }}</p>
                  </div>
                </div>
              </el-col>
            </el-row>
          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<style scoped>
.layout-container {
  height: 100vh;
  font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Arial, sans-serif;
}

/* 侧边栏样式 */
.aside {
  background-color: #2c3e50;
  color: white;
  transition: all 0.3s;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.aside-content {
  padding: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.logo-area {
  padding: 20px;
  text-align: center;
  background-color: #34495e;
  margin-bottom: 20px;
}

.logo-area h2 {
  color: #f1c40f;
  margin: 0;
  font-size: 24px;
  font-weight: bold;
}

.logo-area p {
  color: #bdc3c7;
  margin: 5px 0 0;
  font-size: 12px;
}

.menu {
  border-right: none;
  flex-grow: 1;
}

.menu .el-menu-item {
  height: 50px;
  line-height: 50px;
  margin: 5px 0;
  border-radius: 4px;
  transition: all 0.3s;
}

.menu .el-menu-item:hover {
  background-color: #34495e !important;
}

.menu .el-menu-item.is-active {
  background-color: #3498db !important;
}

/* 头部样式 */
.header {
  background-color: rgba(255, 255, 255, 0.5);
  color: #000000;
  display: flex;
  align-items: center;
  padding: 0 30px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
  width: 100%;
}

.header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 500;
}

.subtitle {
  margin: 5px 0 0;
  font-size: 14px;
  opacity: 0.9;
  font-weight: 300;
}

/* 主内容区样式 */
.main {
  padding: 30px;
  background-color: rgba(255, 255, 255, 0.5);
  overflow-y: auto;

}

.card-container {
  background-color: rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  padding: 25px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
  margin-top: 20px;
}

.section-title {
  color: #2c3e50;
  margin: 0 0 20px;
  font-size: 18px;
  font-weight: 500;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

/* 卡片样式 */
.grid-content {
  border-radius: 8px;
  min-height: 150px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.grid-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(100%);
  transition: transform 0.3s;
}

.grid-content:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.grid-content:hover::before {
  transform: translateY(0);
}

.card-content {
  text-align: center;
  z-index: 1;
}

.card-content h3 {
  margin: 15px 0 8px;
  font-size: 18px;
  font-weight: 500;
}

.card-content p {
  margin: 0;
  font-size: 13px;
  opacity: 0.9;
  font-weight: 300;
}

.icon {
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.2);
  padding: 12px;
  border-radius: 50%;
  transition: transform 0.3s;
}

.grid-content:hover .icon {
  transform: scale(1.1);
}
</style>